package com.bookcloud.java21.chapter10.注解重复注解1012;

import java.util.Arrays;

@Author(
    name = "张三",
    date = "2023-01-01",
    comments = {"这是一个注释"})
@Author(
    name = "李四",
    date = "2023-02-02",
    comments = {"这是另一个注释", "这是第三个注释"})
@Author(
    name = "王五",
    date = "2023-03-03",
    comments = {"这是另一个注释", "这是第三个注释"})
public class RepeatableAnnotationsExample {
  public static void main(String[] args) {
    // 获取类上的注解
    Authors authors = RepeatableAnnotationsExample.class.getAnnotation(Authors.class);
    // 遍历注解
    for (Author author : authors.value()) {
      System.out.println("作者：" + author.name());
      System.out.println("版本：" + author.version());
      System.out.println("日期：" + author.date());
      System.out.println("注释：" + Arrays.toString(author.comments()));
      System.out.println("-----------------");
    }
  }
}
